<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <input id="pageType" th:value="${pageType}" type="hidden">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input id="id" name="id" th:value="${expertExpertsInfo.id}" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">姓名：</label>
                            <div class="col-sm-8">
                                <input id="name" name="name" th:value="${expertExpertsInfo.name}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">性别：</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="gender" name="gender">
                                    <option th:selected="${expertExpertsInfo.gender eq c.key}"
                                            th:each="c:${application.jyrc_xb_}" th:value="${c.key}"
                                            th:text="${c.value}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">身份证：</label>
                            <div class="col-sm-8">
                                <input id="idcard" name="idcard" th:value="${expertExpertsInfo.idcard}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">生日：</label>
                            <div class="col-sm-8">
                                <input id="birthday" name="birthday" th:value="${expertExpertsInfo.birthdayStr}"
                                       class="form-control" type="date">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">学历：</label>
                            <div class="col-sm-8">
                                <input id="record" name="record" th:value="${expertExpertsInfo.record}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">治政面貌：</label>
                            <div class="col-sm-8">
                                <input id="political" name="political" th:value="${expertExpertsInfo.political}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">毕业学校：</label>
                            <div class="col-sm-8">
                                  <input id="graduated0" name="graduated0" th:value="${expertExpertsInfo.graduated}" type="hidden"
                                        class="form-control"> 
                                 <select data-placeholder="选择毕业学校" class="form-control chosen-select" id="graduated" name="graduated" 
                                        tabindex="2" style="width: 100%">
                                    <!-- <option value="">选择毕业学校</option> -->
                                   
                                </select> 

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">专业：</label>
                            <div class="col-sm-4">
                                <input id="professional" name="professional" th:value="${expertExpertsInfo.professional}"
                                      class="form-control" type="text"> 
                            </div>
                             <div class="col-sm-4">
                                <div id="professionalTree"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">专技职务：</label>
                            <div class="col-sm-8">
                                <input id="specialized" name="specialized" th:value="${expertExpertsInfo.specialized}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">专技职务学科：</label>
                            <div class="col-sm-8">
                                <input id="subject" name="subject" th:value="${expertExpertsInfo.subject}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">教师资格证号：</label>
                            <div class="col-sm-8">
                                <input id="qualification" name="qualification"
                                       th:value="${expertExpertsInfo.qualification}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">教师资格类型：</label>
                            <div class="col-sm-8">
                                <input id="qualificationtype" name="qualificationtype"
                                       th:value="${expertExpertsInfo.qualificationtype}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">教师资格任教学科：</label>
                            <div class="col-sm-4">
                               <input id="teachingsubjects" name="teachingsubjects" th:value="${expertExpertsInfo.teachingsubjects}"
                                        class="form-control"
                                       type="text"> 
                            </div>
                            <div class="col-sm-4">
                                <div id="teacherdisciplineTree"></div>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">认定机构：</label>
                            <div class="col-sm-8">
                                <input id="accreditingagencies" name="accreditingagencies"
                                       th:value="${expertExpertsInfo.accreditingagencies}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">现任教学段：</label>
                            <div class="col-sm-8">
                                <input id="thecurrentteaching" name="thecurrentteaching"
                                       th:value="${expertExpertsInfo.thecurrentteaching}" class="form-control"
                                       type="text">

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">现任教学科：</label>
                            <div class="col-sm-4">
                                 <input id="nowteaching" name="nowteaching" th:value="${expertExpertsInfo.nowteaching}"
                                         class="form-control" type="text">

                            </div>
                            <div class="col-sm-4">
                                <div id="teacherdisciplineTree2"></div>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否特级教师：</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="issuper" name="issuper">
                                    <option th:selected="${expertExpertsInfo.issuper eq c.key}"
                                            th:each="c:${application.yes_no_}" th:value="${c.key}"
                                            th:text="${c.value}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">行政职务：</label>
                            <div class="col-sm-8">
                                <input id="administrativeduties" name="administrativeduties"
                                       th:value="${expertExpertsInfo.administrativeduties}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">工作单位：</label>
                            <div class="col-sm-8">
                                <input id="workunits" name="workunits" th:value="${expertExpertsInfo.workunits}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">工作单位地址：</label>
                            <div class="col-sm-8">
                                <input id="workunitsaddress" name="workunitsaddress"
                                       th:value="${expertExpertsInfo.workunitsaddress}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">工作单位邮编：</label>
                            <div class="col-sm-8">
                                <input id="workunitszipcode" name="workunitszipcode"
                                       th:value="${expertExpertsInfo.workunitszipcode}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">工作单位电话：</label>
                            <div class="col-sm-8">
                                <input id="workunitstel" name="workunitstel"
                                       th:value="${expertExpertsInfo.workunitstel}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">家庭地址：</label>
                            <div class="col-sm-8">
                                <input id="homeaddress" name="homeaddress" th:value="${expertExpertsInfo.homeaddress}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">家庭邮编：</label>
                            <div class="col-sm-8">
                                <input id="homezipcode" name="homezipcode" th:value="${expertExpertsInfo.homezipcode}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">家庭电话：</label>
                            <div class="col-sm-8">
                                <input id="hometel" name="hometel" th:value="${expertExpertsInfo.hometel}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">邮箱：</label>
                            <div class="col-sm-8">
                                <input id="email" name="email" th:value="${expertExpertsInfo.email}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">手机：</label>
                            <div class="col-sm-8">
                                <input id="phone" name="phone" th:value="${expertExpertsInfo.phone}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">推荐类别：</label>
                            <div class="col-sm-8">
                                <input id="category" name="category" th:value="${expertExpertsInfo.category}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">科目：</label>
                            <div class="col-sm-4">
                                <input id="course" name="course"
                                       class="form-control" type="text">
                            </div>
                            <div class="col-sm-4">
                          
                                <div id="technologypostTree"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">师教等级：</label>
                            <div class="col-sm-8">
                                <input id="level" name="level" th:value="${expertExpertsInfo.level}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">学校等级：</label>
                            <div class="col-sm-8">
                                <input id="schoollevel" name="schoollevel" th:value="${expertExpertsInfo.schoollevel}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否培训：</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="istrain" name="istrain">
                                    <option th:selected="${expertExpertsInfo.istrain eq c.key}"
                                            th:each="c:${application.yes_no_}" th:value="${c.key}"
                                            th:text="${c.value}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">培训时间：</label>
                            <div class="col-sm-8">
                                <input id="traintime" name="traintime" th:value="${expertExpertsInfo.traintimeStr}"
                                       class="form-control" type="date">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">活动次数：</label>
                            <div class="col-sm-8">
                                <input id="exnumber" name="exnumber" th:value="${expertExpertsInfo.exnumber}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">工作经验：</label>
                            <div class="col-sm-8">
                                <input id="workexperience" name="workexperience"
                                       th:value="${expertExpertsInfo.workexperience}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所属区域：</label>
                            <div class="col-sm-8">
                                <input id="areaid" name="areaid" th:value="${expertExpertsInfo.areaid}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">推荐类别：</label>
                            <div class="col-sm-8">
                                <input id="recommendstate" name="recommendstate"
                                       th:value="${expertExpertsInfo.recommendstate}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">银行卡1号码：</label>
                            <div class="col-sm-8">
                                <input id="bankcardcode1" name="bankcardcode1"
                                       th:value="${expertExpertsInfo.bankcardcode1}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">银行卡1类型：</label>
                            <div class="col-sm-8">
                                <input id="bankcardtype1" name="bankcardtype1"
                                       th:value="${expertExpertsInfo.bankcardtype1}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">银行卡2号码：</label>
                            <div class="col-sm-8">
                                <input id="bankcardcode2" name="bankcardcode2"
                                       th:value="${expertExpertsInfo.bankcardcode2}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">银行卡2类型：</label>
                            <div class="col-sm-8">
                                <input id="bankcardtype2" name="bankcardtype2"
                                       th:value="${expertExpertsInfo.bankcardtype2}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">培训状态：</label>
                            <div class="col-sm-8">
                                <input id="nettrainstatus" name="nettrainstatus"
                                       th:value="${expertExpertsInfo.nettrainstatus}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    $().ready(function () {
        var pageType = $('#pageType').val();
        if ('save' == pageType) {//新增页面
            getprofessionalTreeDataAdd();
            getteacherdisciplineTreeDataAdd();
            gettechnologypostTreeDataAdd();
            selectSChool();
            validateRule();

        } else if ('update' == pageType) {//修改页面
        	getprofessionalTreeDataAdd();
            getteacherdisciplineTreeDataAdd();
            gettechnologypostTreeDataAdd();
            selectSChool();
            var graduated = $("#graduated0").val();
            $("#graduated").find("option[text='"+graduated+"']").attr("selected",true);
            validateRule();

        } else {
            parent.layer.msg("页面参数错误");
        }
    });

    $.validator.setDefaults({
        submitHandler: function () {
            save();
        }
    });
   
    //毕业学校
    function selectSChool() {
        var type= 'graduateschool';
        var html = "";
        $.ajax({
            url : "/experts/expertExpertsInfo/getTreeData/" + type,
            success : function(data) {
                data = data.data;
                //加载数据
                for (var i = 0; i < data.length; i++) {
                    html += '<option value="' + data[i].text  + '">' + data[i].text  + '</option>'
                }
                $(".chosen-select").append(html);
                $(".chosen-select").chosen({
                    maxHeight : 200
                });
            }
        });
    }

    //专业树
    function getprofessionalTreeDataAdd() {
        var type= 'studyspecial';
        $.ajax({
            type : "GET",
            url : "/experts/expertExpertsInfo/getTreeData/" + type,
            success : function(professionalTree) {
                $('#professionalTree').jstree({
                    "plugins" : [ "wholerow","checkbox"],
                    'core' : {
                    	'multiple': false,
                        'data' : professionalTree.data[0]
                    },
                    "checkbox" : {
                    }
                });
                /* $('#professionalTree').jstree('open_all'); */
            }
        });
    }

    $('#professionalTree').on('changed.jstree',function(e,data){
    	             console.log(data.instance.get_node(data.selected[0]).text);
    	             $("#professional").val(data.instance.get_node(data.selected[0]).text); 
    	        });
    $('#teacherdisciplineTree').on('changed.jstree',function(e,data){
    	             console.log(data.instance.get_node(data.selected[0]).text);
    	             $("#teachingsubjects").val(data.instance.get_node(data.selected[0]).text); 
    	        });
    $('#teacherdisciplineTree2').on('changed.jstree',function(e,data){
    	             console.log(data.instance.get_node(data.selected[0]).text);
    	             $("#nowteaching").val(data.instance.get_node(data.selected[0]).text); 
    	        });
    $('#technologypostTree').on('changed.jstree',function(e,data){
    	             console.log(data.instance.get_node(data.selected[0]).text);
    	             $("#course").val(data.instance.get_node(data.selected[0]).text); 
    	        });
    //任教学科树
    function getteacherdisciplineTreeDataAdd() {
        var type= 'teacherdiscipline';
        $.ajax({
            type : "GET",
            url : "/experts/expertExpertsInfo/getTreeData/" + type,
            success : function(teacherdisciplineTree) {
                $('#teacherdisciplineTree').jstree({
                    "plugins" : [ "wholerow","checkbox"],
                    'core' : {
                    	'multiple': false,
                        'data' : teacherdisciplineTree.data[0]
                    },
                    "checkbox" : {
                        "three_state" : true
                    }
                });

                $('#teacherdisciplineTree2').jstree({
                    "plugins" : [ "wholerow","checkbox"],
                    'core' : {
                    	'multiple': false,
                        'data' : teacherdisciplineTree.data[0]
                    },
                    "checkbox" : {
                        "three_state" : true
                    }
                });
                /* $('#professionalTree').jstree('open_all'); */
            }
        });
    }


    //职称树
    function gettechnologypostTreeDataAdd() {
        var type= 'technologypost';
        $.ajax({
            type : "GET",
            url : "/experts/expertExpertsInfo/getTreeData/" + type,
            success : function(technologypostTree) {
                $('#technologypostTree').jstree({
                    "plugins" : [ "wholerow","checkbox"],
                    'core' : {
                    	'multiple': false,
                        'data' : technologypostTree.data[0]
                    },
                    "checkbox" : {
                        "three_state" : true
                    }
                });
                /* $('#professionalTree').jstree('open_all'); */
            }
        });
    }


    function save() {
        $.ajax({
            cache: true,
            type: "POST",
            url: "/experts/expertExpertsInfo/" + $('#pageType').val(),
            data: $('#signupForm').serialize(),// 你的formid
            async: false,
            error: function (request) {
                parent.layer.alert("Connection error");
            },
            success: function (data) {
                if (data.code == 0) {
                    parent.layer.msg("操作成功");
                    //parent.reLoad();
                    $(window.parent.document).find('.J_iframe').each(function () {
                        if ($(this).data('id') == "/experts/expertExpertsInfo") {///experts/expertExpertsInfo为打开的frame id
                            this.contentWindow.reLoad();
                            return false;
                        }
                    });
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);

                } else {
                    parent.layer.alert(data.msg)
                }

            }
        });

    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                name: {
                    required: true
                }
            },
            messages: {
                name: {
                    required: icon + "请输入名字"
                }
            }
        })
    }
</script>
</body>
</html>